home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 41 / Issue 41.iso / pc / PCSoftware / Netscape 6 Official Release / nim.xpi / bin / chrome / aim.jar / content / aim / chatPanel.js < prev    next >
Encoding:
JavaScript  |  2000-05-26  |  5.3 KB  |  202 lines

  1. /*
  2.  
  3. ChatPanel.js
  4.  
  5.  
  6. */
  7.  
  8. //create template for user management.
  9.  
  10. function chatPanelObj(){
  11.  
  12.     this.chatPanelAddScreenName = chatPanelAddScreenName;
  13.     this.chatPanelRemoveScreenName = chatPanelRemoveScreenName;
  14.     this.chatPanelUpdateScreenName = chatPanelUpdateScreenName;
  15.     
  16.     return this;
  17. }
  18.  
  19. myChatPanel = new chatPanelObj()
  20.  
  21.  
  22. function chatPanelOnWinLoad(){
  23.     
  24.     try{
  25.     
  26.     if(parent.myManager && parent.chatPanelLoaded){
  27.         dump("chatPanelOnWinLoad - parent.myManager defined \n")
  28.         for(z=0;z<parent.myManager.members.length;z++){
  29.             chatPanelUpdateScreenName(parent.myManager.members[z].screenName,parent.myManager.members[z].status)
  30.         }
  31.     
  32.     }
  33.     else{
  34.         dump("chatPanelOnWinLoad -parent.myManager not defined \n")
  35.     }
  36.     }
  37.     catch (e){
  38.         dump("chatPanelOnWinLoad : couldnt find parent.myManager (caught exception) \n")
  39.     }
  40.     
  41.     parent.chatPanelLoaded=true;
  42. }
  43.  
  44.  
  45. function chatPanelAddScreenName(screenName,initialState){
  46.     dump('adding:'+screenName+"\n\n")
  47.     //get current tree
  48.     theTree = document.getElementById("cptChildren");
  49.     // build new tree branch
  50.     newTreeItem=document.createElement("treeitem");
  51.     newTreeItem.setAttribute('value',screenName)
  52.  
  53.     newTreeRow=document.createElement("treerow");
  54.     newTreeCell=document.createElement("treecell");
  55.     //newTreeCell.setAttribute('src','chrome://aim/skin/aimworld.gif');
  56.     newTreeCell.setAttribute('value',screenName);
  57.     newTreeCell.setAttribute('class',initialState);
  58.     
  59.     dump("chatPanelAddScreenName adding class value of"+initialState);
  60.     
  61.     newTreeRow.appendChild(newTreeCell)
  62.     newTreeItem.appendChild(newTreeRow)
  63.     
  64.     theTree.appendChild(newTreeItem)
  65.     
  66.     top.updateMemberCount();
  67.     //top.updateStatus(screenName+" > "+initialState)
  68.     top.chatContentStatusChange(screenName,initialState)
  69.  
  70.  
  71. }
  72.  
  73.  
  74. function chatPanelRemoveScreenName(screenName){
  75.     dump('removing:'+screenName+'\n\n')
  76.         theTree = document.getElementById("cptChildren");
  77.         //theDoomedScreenName = document.getElementById(screenName)
  78.         
  79.         //theDoomedScreenName = document.getElementsByAttribute('value',screenName.toLowerCase()).item(0)
  80.         
  81.         var theTreeChildren = document.getElementsByTagName("treecell");
  82.         var theDoomedScreenName = null;
  83.         
  84.         for(k=0; k<theTreeChildren.length; k++){
  85.             if(theTreeChildren.item(k).getAttribute("value").toLowerCase() == screenName.toLowerCase()){
  86.                 theDoomedScreenName = theTreeChildren.item(k);
  87.             }
  88.         
  89.         }
  90.  
  91.         if(theDoomedScreenName != null){
  92.         
  93.             theTree.removeChild(theDoomedScreenName.parentNode.parentNode)
  94.             top.updateMemberCount();
  95.             //top.updateStatus(screenName+"has left")
  96.             top.chatContentStatusChange(screenName,"has left")
  97.  
  98.         }
  99.         else{
  100.             dump("chatPanelRemoveScreenName: cannot remove "+screenName+"\n");
  101.         }
  102.  
  103.  
  104. }
  105.  
  106. //update the status of a given screenname
  107.  
  108. function chatPanelUpdateScreenName(screenName,snStatus){
  109.     dump("updating status of "+screenName+" to "+snStatus+"\n");
  110.     //var searchingSN = screenName.toLowerCase()
  111.     //var theSNtoUpdate = document.getElementById(searchingSN)
  112.     var theTreeChildren = document.getElementsByTagName("treecell");
  113.     var theSNtoUpdate= null;
  114.     for (j=0; j<theTreeChildren.length; j++){
  115.         if(aimIsSameScreenName(theTreeChildren.item(j).getAttribute("value"), screenName)){
  116.             theSNtoUpdate = theTreeChildren.item(j);
  117.             dump("ChatPanelUpdate:found the child +\n" )
  118.         }
  119.     }
  120.  
  121.  
  122.     
  123.     if(theSNtoUpdate!=null){
  124.         dump("they already were here in some state.(invited?)\n")
  125.         theSNtoUpdate.setAttribute("class",snStatus);
  126.  
  127.         // in case its formatting has changed
  128.         theSNtoUpdate.setAttribute("value", screenName);
  129.         top.updateMemberCount();
  130.  
  131.         top.chatContentStatusChange(screenName,snStatus)
  132.  
  133.     }
  134.     else{
  135.         dump(" they joined without being invited? \n")
  136.         chatPanelAddScreenName(screenName,snStatus)
  137.     }
  138.  
  139. }
  140.  
  141.  
  142. function cmdUserSelected(e){
  143.     document.getElementById("userSelected").setAttribute("disabled","false")
  144.     //var targetValue=e.target.getAttribute("value");
  145.  
  146.     //dump("userSelected:"+targetValue+"\n")
  147.     var theTree = document.getElementById("chatPanelTree")
  148.     if(theTree.selectedItems.length==1){
  149.         dump('elementSelected:' + theTree.selectedItems[0].tagName +"\n")
  150.         document.getElementById("userSelected").setAttribute("disabled","false")
  151.  
  152.     }
  153.     if(theTree.selectedItems.length==0){
  154.         document.getElementById("userSelected").setAttribute("disabled","true")
  155.  
  156.     }
  157.  
  158. }
  159.  
  160. function cmdUserBlurred(e){
  161.     //document.getElementById("userSelected").setAttribute("disabled","true")
  162.         dump("userBlurred:"+e.target.tagName+"\n")
  163.  
  164. }
  165.  
  166.  
  167.  
  168. function cmdSendIMFromChat(){
  169.     var theTree = document.getElementById("chatPanelTree")
  170.     if(theTree.selectedItems.length==1){
  171.         var selectedScreenName =theTree.selectedItems[0].childNodes[0].childNodes[0].getAttribute("value") 
  172.         
  173.         aimIMInvokeIMForm(selectedScreenName, null);
  174.  
  175.     }
  176. }
  177.  
  178. function cmdIgnoreFromChat() 
  179. {
  180.     var theTree = document.getElementById("chatPanelTree")
  181.     var i;
  182.     for (i = 0; i < theTree.selectedItems.length; i++)
  183.     {
  184.         var selectedScreenName =theTree.selectedItems[i].childNodes[0].childNodes[0].getAttribute("value");
  185.  
  186.         var wasIgnored = top.chatRoomObj.Ignore(selectedScreenName);
  187.         if (wasIgnored)
  188.         top.frames['chatpanel'].chatPanelUpdateScreenName(selectedScreenName, "joined treecell-iconic");
  189.        else
  190.         top.frames['chatpanel'].chatPanelUpdateScreenName(selectedScreenName, "ignored treecell-iconic");
  191.         
  192.     }
  193. }
  194.  
  195. function getInfoFromChat()
  196. {
  197.   return;
  198. }
  199.  
  200.  
  201.  
  202.